<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('操作日志列表')"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="operlog-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>操作用户：</label><input type="text" name="operater"/>
                        </li>
                        <li>
                            <label>操作ip：</label><input type="text" name="ip"/>
                        </li>
                        <li>
                            <label>操作地区：</label><input type="text" name="location"/>
                        </li>
                        <li>
                            <label>操作系统：</label><input type="text" name="os"/>
                        </li>
                        <li>
                            <label>浏览器：</label><input type="text" name="browser"/>
                        </li>
                        <li>
                            业务类型：<select name="businessType"
                                         th:with="dicts=${@sysDictDataServiceImpl.listDictDataByTypeSign('sys_business_type')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${dicts}" th:text="${dict.dataKey}"
                                    th:value="${dict.dataValue}"></option>
                        </select>
                        <li>
                            操作结果：<select name="success"
                                         th:with="dicts=${@sysDictDataServiceImpl.listDictDataByTypeSign('sys_login_log_result')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${dicts}" th:text="${dict.dataKey}"
                                    th:value="${dict.dataValue}"></option>
                        </select>
                        </li>
                        <li class="select-time">
                            <label>操作时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-danger" onclick="$.operate.clean()">
                <i class="fa fa-trash"></i> 清空
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-select-js"/>
<script th:inline="javascript">
    const sys_login_log_result = [[${@sysDictDataServiceImpl.listDictDataByTypeSign('sys_login_log_result')}]];
    const sys_business_type = [[${@sysDictDataServiceImpl.listDictDataByTypeSign('sys_business_type')}]];
    const prefix = ctx + "system/log/operate";

    $(function () {
        const options = {
            url: prefix + "/list",
            cleanUrl: prefix + "/clean",
            detailUrl: prefix + "/detail/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "操作日志",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            columns: [{
                field: 'state',
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false,
                    sortable: true
                },
                {
                    field: 'operater',
                    title: '操作用户',
                    sortable: true
                },
                {
                    field: 'module',
                    title: '系统模块'
                },
                {
                    field: 'businessType',
                    title: '业务类型',
                    align: 'center',
                    formatter: function (value, item, index) {
                        return $.table.selectDictLabel(sys_business_type, item.businessType);
                    }
                },
                {
                    field: 'success',
                    title: '操作结果',
                    align: 'center',
                    formatter: function (value, item, index) {
                        return $.table.selectDictLabel(sys_login_log_result, item.success);
                    }
                },
                {
                    field: 'ip',
                    title: 'IP'
                },
                {
                    field: 'location',
                    title: '登录地点'
                },
                {
                    field: 'browser',
                    title: '浏览器'
                },
                {
                    field: 'os',
                    title: '操作系统'
                },
                {
                    field: 'createTime',
                    title: '登录时间',
                    sortable: true
                },
                {
                    field: 'message',
                    title: '信息',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.operId + '\')"><i class="fa fa-search"></i>详细</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>